package com.dr.common.ution;

import java.io.*;

/**
 * Created by su on 2017/4/26 0026 00:37
 * 619389279@qq.com
 */
public class SaveFileUtil {

    public static boolean saveFileInStrenm(InputStream inStream, String mFilePath, String mFileName) {
        String mSaveFilePath = mFilePath + "/" + mFileName;
        //创建文件夹
        if (FileUtils.createOrExistsDir(mFilePath)) {
            //文件是否存在，存在则删除
            if (FileUtils.createFileByDeleteOldFile(mSaveFilePath)) {
                if (FileUtils.writeFileFromIS(mSaveFilePath, inStream, false)) {
                    return true;
                } else {
                    System.out.println(mFileName+"写入流失敗");
                    return false;
                }
            } else {
                System.out.println(mFileName+"文件创建失败");
                return false;
            }
        } else {
            System.out.println(mFileName+"创建文件夹失败");
            return false;
        }
    }

}
